<?php

/**
 * This is the model class for table "tbl_subscription".
 *
 * The followings are the available columns in table 'tbl_subscription':
 * @property string $id
 * @property string $start_date
 * @property string $current_period_start
 * @property string $current_period_end
 * @property string $payed
 * @property string $paused_date
 * @property string $fixed_ip
 * @property integer $status
 * @property string $reminder
 * @property string $tbl_client_id
 * @property string $tbl_subscription_type_id
 * @property string $tbl_subscription_plan_id
 */
class Subscription extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Subscription the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_subscription';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('start_date, tbl_client_id, tbl_subscription_type_id, tbl_subscription_plan_id', 'required'),
			array('status', 'numerical', 'integerOnly'=>true),
			array('fixed_ip', 'length', 'max'=>30),
			array('tbl_client_id', 'length', 'max'=>20),
			array('tbl_subscription_type_id, tbl_subscription_plan_id', 'length', 'max'=>10),
			array('current_period_start, current_period_end, payed, paused_date, reminder', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, start_date, current_period_start, current_period_end, payed, paused_date, fixed_ip, status, reminder, tbl_client_id, tbl_subscription_type_id, tbl_subscription_plan_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'start_date' => 'Start Date',
			'current_period_start' => 'Current Period Start',
			'current_period_end' => 'Current Period End',
			'payed' => 'Payed',
			'paused_date' => 'Paused Date',
			'fixed_ip' => 'Fixed Ip',
			'status' => 'Status',
			'reminder' => 'Reminder',
			'tbl_client_id' => 'Tbl Client',
			'tbl_subscription_type_id' => 'Tbl Subscription Type',
			'tbl_subscription_plan_id' => 'Tbl Subscription Plan',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('start_date',$this->start_date,true);
		$criteria->compare('current_period_start',$this->current_period_start,true);
		$criteria->compare('current_period_end',$this->current_period_end,true);
		$criteria->compare('payed',$this->payed,true);
		$criteria->compare('paused_date',$this->paused_date,true);
		$criteria->compare('fixed_ip',$this->fixed_ip,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('reminder',$this->reminder,true);
		$criteria->compare('tbl_client_id',$this->tbl_client_id,true);
		$criteria->compare('tbl_subscription_type_id',$this->tbl_subscription_type_id,true);
		$criteria->compare('tbl_subscription_plan_id',$this->tbl_subscription_plan_id,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}